﻿using StockholmsStad.Windows.UI.Modules.Couple.Interfaces;
using StockholmsStad.Windows.UI.Modules.Couple.Models;
using StockholmsStad.Runtime.Serialization.DataContract;
using StockholmsStad.Runtime.Serialization.DataContract.Enums;

namespace StockholmsStad.Windows.UI.Modules.Couple.Views
{
    /// <summary>
    /// Interaction logic for TabItemLawTextsView.xaml
    /// </summary>
    public partial class TabItemLawTextsView : ILawTextsView
    {
        private readonly ILawTextService service;

        public TabItemLawTextsView(ILawTextService service)
        {
            InitializeComponent();
            this.service = service;
            Loaded += TabItemLawTextsView_Loaded;
        }

        private void TabItemLawTextsView_Loaded(object sender, System.Windows.RoutedEventArgs e)
        {
            Model = service.GetLawTexts(InformationTextType.LawText);
        }

        #region ILawTextsView Members

        public LawTextsPresentationModel Model
        {
            get { return DataContext as LawTextsPresentationModel; }
            set { DataContext = value; }
        }

        #endregion

        private void cbHeaders_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
        {
            var text = cbHeaders.SelectedItem as InformationText;
            tblContent.Text = text != null ? text.Content : string.Empty;
        }
    }
}






